home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-01-24 | 4.3 KB | 121 lines | [TEXT/MPS ] |
- #
- # makelist
- # MPW Shell script
- # Malcolm H. Teas
- # Apple Computer, Inc.
- #
- # Function:
- # Help the user build a list of corresponding files from a
- # master to a test disk. It does this by generating a list
- # of the files on the two disks and asking the user (via dialog
- # boxes) for the names of the test files that it cannot figure out.
- #
- # In & Outputs:
- # There are two input parameters and the sole output parm is the exit status.
- # The correspondences file is also generated as output. The first input
- # parm is the filename for the correspondences file. The second is the "d"
- # for "disk", or "f" for "folder" parameter telling makelist where the
- # files to search are.
- #
- # Set the variable names.
- set save-echo {echo} # echo=1 for echoing each command before execution
- set echo 0
-
- set outfile "{1}"
- set folder "{2}"
- # Clear the outfile if it exists.
- if `exists "{outfile}"`
- delete "{outfile}"
- end
-
- # Set the Us and localdisk variables. These will be used later to
- # know where to look for the files to correspond.
- if "{folder}" == "d" # If we're in disk mode then...
- # Ask the user to select the US disk, the original from which the test
- # version was made.
- set USdisk "`volumes -q | getlistitem -q -m "Select the MASTER disk please:" || ∂
- set sstatus {status}`"
- if {sstatus} != 0 # Test for cancel button
- set echo {save-echo}
- exit 2
- end
-
- # Now get the test disk.
- set Localdisk "`volumes -q | getlistitem -q -m "Select the TEST disk please:" || ∂
- set sstatus {status}`"
- if {sstatus} != 0 # Test for cancel button
- set echo {save-echo}
- exit 2
- end
- else # Pick from folders, not disks.
- # Ask the user to select the US folder, the original from which the test
- # version was made.
- set USdisk "`getfilename -q -d -m "Select the MASTER folder" || ∂
- set sstatus {status}`"
- if {sstatus} != 0 # Test for cancel button
- set echo {save-echo}
- exit 2
- end
- set save-dir "`directory`"
- directory "{USdisk}"
- directory ::
- set rmstring "`directory`"
-
- # Now get the test disk.
- set Localdisk "`getfilename -q -d -m "Select the TEST folder" || ∂
- set sstatus {status}`"
- if {sstatus} != 0 # Test for cancel button
- set echo {save-echo}
- exit 2
- end
- directory {save-dir}
- end # picked from either disks or folders.
-
- # Get the file list for the US disk. The options ask for recursive
- # search, full pathnames, and files only. The output file is a temp file.
- files -r -f -s "{Localdisk}" > "{outfile}".local
-
- # Loop on the US files and prompt the user for the test files we cannot
- # figure out. Use the type and creator of the US files to search for the
- # test file. If we find only one, it must be the file we're looking for.
- # If we find more than one, ask the user for help. The following echos are
- # a little tricky, since the following scripts will depend on the format
- # precisely. Changes here mean changes there.
- for file in `catenate "{outfile}".local`
- continue if "{file}" =~ /≈Desktop/ # Skip the desktop file.
- # Search the localdisk. The output of this files should NOT be quoted (-q).
- # Remember to quote the creator to include possible trailing spaces!
- files -r -f -s -q -t `catinfo -t -q "{file}"` -c "`catinfo -c -q "{file}"`" "{USdisk}" > "{outfile}".us
- if `count -l "{outfile}".us` == 1 # If only one line of output...
- catenate "{outfile}".us >> "{outfile}"
- echo "{file}" >> "{outfile}" # Add it now.
- continue # And don't ask the user.
- end
- # If there is more than one, ask the user for help in choosing.
- set tmp "`getlistitem -q -m "The Master ∂"{file}∂" is" < "{outfile}".us ∂
- || set sstatus {status}`"
- if {sstatus} != 0 # If cancel, then cleanup and exit.
- delete "{outfile}".us "{outfile}".local
- exit 2
- end # end of if cancel
- echo "{tmp}" >> "{outfile}"
- echo "{file}" >> "{outfile}" # Add the user's choice to the list.
- end
- # If the folder option was set, we need to clean up the filelist so that it
- # would appear the same as if the disk option was set. This is so that
- # filelists from disk or folder source can be used interchangably.
- if "{folder}" == f
- open "{outfile}" # Get the file.
- loop
- clear /{rmstring}/ "{outfile}" # Remove directory string.
- if {status} != 0 # End of list.
- break
- end
- end
- close -y "{outfile}" # All done! (Feel better now?)
- end
-
- # Clean up and exit.
- delete "{outfile}".us "{outfile}".local # Remove the temp files.
- set echo {save-echo}
- exit 0